package com.pds.web.testOrganization.controller;


import com.pds.common.core.controller.BaseController;
import com.pds.common.core.domain.R;
import com.pds.common.core.page.TableDataInfo;
import com.pds.web.testOrganization.domain.OrganizationStatusDTO;
import com.pds.web.testOrganization.domain.PdsTestOrganizationVO;
import com.pds.web.testOrganization.service.IPdsTestOrganizationVOService;
import com.pds.web.testOrganizationInfo.domain.PdsTestOrganizationInfo;
import com.pds.web.testOrganizationInfo.service.IPdsTestOrganizationInfoService;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Api
@RestController
@RequestMapping("/testOrganization")
public class PdsTestOrganizationVOController extends BaseController {

    @Autowired
    private IPdsTestOrganizationVOService pdsTestOrganizationVOService;

//    @Autowired
//    private IPdsTestOrganizationInfoService pdsTestOrganizationInfoService;

//    @GetMapping("/listAll")
//    public TableDataInfo listAll(PdsTestOrganizationInfo pdsTestOrganizationInfo){
//        startPage();
//        List<PdsTestOrganizationInfo> pdsTestOrganizationInfoList = pdsTestOrganizationVOService.selectInfoList(pdsTestOrganizationInfo);
//        return getDataTable(pdsTestOrganizationInfoList);
//    }
//
//    @GetMapping("/listInfo/{organizationId}")
//    public R<PdsTestOrganizationVO> list(@PathVariable Long organizationId){
//
//        PdsTestOrganizationVO pdsTestOrganizationVO = pdsTestOrganizationVOService.listById(organizationId);
//        return R.ok(pdsTestOrganizationVO);
//    }

    @GetMapping("/detailList")
    public TableDataInfo detailList(){
        startPage();
        List<PdsTestOrganizationVO> list = pdsTestOrganizationVOService.detailList();
        TableDataInfo dataTable = getDataTable(list);
        int total = pdsTestOrganizationVOService.getTotal();
        dataTable.setTotal(total);
        return dataTable;
    }

    @PutMapping("/updateStatus")
    public R<Boolean> update(@RequestBody OrganizationStatusDTO statusDTO){
//        boolean flag1 = pdsTestOrganizationVOService.updateInfoStatus(statusDTO);
//        boolean flag2 = pdsTestOrganizationVOService.updateHonorStatus(statusDTO);
//        boolean flag3 = pdsTestOrganizationVOService.updateInspectStatus(statusDTO);
//        boolean flag4 = pdsTestOrganizationVOService.updateQualificationStatus(statusDTO);
//        boolean flag5 = pdsTestOrganizationVOService.updatePersonStatus(statusDTO);
//        boolean flag6 = pdsTestOrganizationVOService.updatePlaceStatus(statusDTO);
//        boolean flag = flag1&flag2&flag3&flag4&flag5&flag6;
//        System.out.println(statusDTO.getStatus());
//        System.out.println(status);
//        pdsTestOrganizationVOService.updateHonorStatus(organizationId, status);
        return R.ok(pdsTestOrganizationVOService.updateInfoStatus(statusDTO));
    }
}
